home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / gui / prcgntn1.lha / Precognition / source / HSlider.c < prev    next >
C/C++ Source or Header  |  1992-12-23  |  4KB  |  182 lines

  1. /* ==========================================================================
  2. **
  3. **                         HSlider.c
  4. ** ⌐1991 WILLISoft
  5. **
  6. ** ==========================================================================
  7. */
  8.  
  9. #include "minmax.h"
  10. #include "HSlider.h"
  11. #include "HSliderClass.h"
  12. #include <proto/exec.h>
  13. #include <proto/intuition.h>
  14. #include "amigamem.h"
  15.  
  16.  
  17. tPoint HSlider_AskSize( HSlider *self,
  18.                         PIXELS  Width,
  19.                         PIXELS  Height )
  20. {
  21.    tPoint size;
  22.  
  23.    size.x = MAX( Width,  20 );
  24.    size.y = MAX( Height, 10 );
  25.  
  26.    return size;
  27. }
  28.  
  29.  
  30.  
  31. LONG HSlider_Value( HSlider *self )
  32. {
  33.    return self->Prop.HorizPot;
  34. }
  35.  
  36.  
  37. USHORT HSlider_KnobSize( HSlider *self )
  38. {
  39.    return self->Prop.HorizBody;
  40. }
  41.  
  42.  
  43. LONG HSlider_SetValue( HSlider *self, LONG value )
  44. {
  45.    struct pcgWindow *window;
  46.    struct PropInfo   propinfo;
  47.    USHORT position;
  48.    
  49.    position = value;
  50.    propinfo = self->Prop;
  51.  
  52.    if ((window = InteractorWindow( self )) &&
  53.        (window->Window))
  54.    {
  55.       NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  56.          position, propinfo.VertPot,
  57.          propinfo.HorizBody, propinfo.VertBody,
  58.          1 );
  59.    }
  60.    else
  61.    {
  62.       self->Prop.HorizPot  = position;
  63.    }
  64.  
  65.    return position;
  66. }
  67.  
  68.  
  69. USHORT HSlider_SetKnobSize( HSlider *self, USHORT knobsize )
  70. {
  71.    struct pcgWindow *window;
  72.    struct PropInfo   propinfo;
  73.  
  74.    propinfo = self->Prop;
  75.  
  76.    if ((window = InteractorWindow( self )) &&
  77.        (window->Window))
  78.    {
  79.       NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  80.          propinfo.HorizPot,  propinfo.VertPot,
  81.          knobsize, propinfo.VertBody,
  82.          1 );
  83.    }
  84.    else
  85.    {
  86.       self->Prop.HorizBody = knobsize;
  87.    }
  88.  
  89.    return knobsize;
  90. }
  91.  
  92.  
  93. #ifdef BUILDER
  94. #include "BuilderMethods.h"
  95. #include "GraphicObject_Builder.h"
  96. #include "Positioner_Builder.h"
  97. #include "Positioner_Coder.h"
  98.  
  99. Slider *HSlider_New( HSlider *self )
  100. {
  101.    Slider *new_HSlider = NULL;
  102.    Point loc, size;
  103.  
  104.    if (new_HSlider = (HSlider *) Amalloc(sizeof(HSlider)))
  105.    {
  106.       loc  = Location(self);
  107.       size = Size(self);
  108.  
  109.       HSlider_Init( new_HSlider, loc.x, loc.y, size.x, size.y,
  110.                     self->eg.Pens, Title(self) );
  111.       GiveItAName( new_HSlider );
  112.    }
  113.    return new_HSlider;
  114. }
  115. struct BuilderMethods HSlider_bm;
  116. #endif
  117.  
  118.  
  119. BOOL HSlider_elaborated = FALSE;
  120.  
  121. struct PositionerClass HSlider_Class;
  122.  
  123. void HSliderClass_Init( struct PositionerClass *class )
  124. {
  125.    SliderClass_Init( class );
  126.    class->isa         = SliderClass();
  127.    class->ClassName   = "HSlider";
  128.    class->AskSize     = HSlider_AskSize;
  129.    class->SetValue    = HSlider_SetValue;
  130.    class->Value       = HSlider_Value;
  131.    class->SetKnobSize = HSlider_SetKnobSize;
  132.    class->KnobSize    = HSlider_KnobSize;
  133.  
  134. #ifdef BUILDER
  135.    go_InitBuilderMethods( &HSlider_bm );
  136.    HSlider_bm.New        = HSlider_New;
  137.    HSlider_bm.PropEdit   = Positioner_PropEdit;
  138.    HSlider_bm.WriteCode  = Positioner_WriteCode;
  139.    class->BuilderMethods = &HSlider_bm;
  140. #endif
  141.  
  142. }
  143.  
  144.  
  145. struct PositionerClass *HSliderClass( void )
  146. {
  147.    if (! HSlider_elaborated)
  148.    {
  149.       HSliderClass_Init( &HSlider_Class );
  150.       HSlider_elaborated = TRUE;
  151.    }
  152.  
  153.    return &HSlider_Class;
  154. }
  155.  
  156.  
  157. void HSlider_Init( HSlider    *self,
  158.                    PIXELS      LeftEdge,
  159.                    PIXELS      TopEdge,
  160.                    PIXELS      Width,
  161.                    PIXELS      Height,
  162.                    pcg_3DPens  Pens,
  163.                    char       *label )
  164. {
  165.    Point size;
  166.  
  167.    size = HSlider_AskSize( self, Width, Height );
  168.  
  169.    Slider_Init( self, LeftEdge, TopEdge, size.x, size.y, Pens );
  170.  
  171.    self->eg.isa        = HSliderClass();
  172.    self->Prop.Flags   |= FREEHORIZ;
  173.    self->Prop.HorizBody = 0x4000;
  174.  
  175.    SetTitle( self, label );
  176.    SetTextAlignment( self, tx_OUTSIDE | tx_LEFT | tx_YCENTER,
  177.       STD_XPAD, STD_YPAD );
  178. }
  179.  
  180.  
  181.  
  182.